/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package percistence;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import model.Aluno;
import model.Exercicio;

/**
 *
 * @author Webert
 */
public class ExercicioDAO {
      private static ExercicioDAO instance= new ExercicioDAO();
  
  private ExercicioDAO() {}
  
  public static ExercicioDAO getInstance() {
    return instance;
  }
  
   public void salvar(Exercicio exercicio) throws ClassNotFoundException{
    Connection conn = null;
    Statement st  = null;

    try {
      conn = DatabaseLocator.getInstance().getConnection();
      st = conn.createStatement();
      st.execute("insert into exercicio (serie, repeticao)" +
        " values ('" + exercicio.getSerie() + "', '" + exercicio.getRepeticao() + "')");
    } catch(SQLException e) {
        e.printStackTrace();
    } finally {
      closeResources(conn, st);
    }
   }
   
   public void alterar(Aluno aluno){
   
   }
   
   public void excluir(Integer id){
   
   }
   
   public void consultar(Integer id){
   
   }
  
    public void closeResources(Connection conn, Statement st) {
    try {
      if(st!=null) st.close();
      if(conn!=null) conn.close();
      
    } catch(SQLException e) {
      
    }
  }
}
